package com.samphanie.admin.modules.sys.controller;

import com.samphanie.admin.modules.sys.domain.dto.LoginDto;
import com.samphanie.admin.modules.sys.domain.vo.Oauth2TokenVo;
import com.samphanie.admin.modules.sys.service.ISysUserService;
import com.samphanie.common.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 授权认证服务
 * @author ZSY
 * @date 2021/11/9 13:34
 */
@Api(tags = "login")
@RestController
@RequestMapping("/api/v1/authorize")
@RequiredArgsConstructor
public class AuthorizeController {

    private final ISysUserService userService;

    @ApiOperation("用户名密码登录")
    @PostMapping("/login")
    public ApiResponse<Oauth2TokenVo> login(@Valid @RequestBody LoginDto loginDto) {
        return ApiResponse.success(userService.userLogin(loginDto));
    }

}
